#include <algorithm>
#include <cctype>
#include <cstdio>

//TODO:...
const int N = 10000;
int n, q, add;
char opt[3];

struct Node {
  int fa, ch[2], d, val, tag;
};

struct LeftistTree {
  Node tr[N];

  int find(int x) { return tr[x].fa == x ? x : tr[x].fa = find(tr[x].fa); }

  int merge(int x, int y) {
    if (!x || !y) return x | y;
    if (tr[x].val < tr[y].val) std::swap(x, y);
    pushdown(x), pushdown(y);
    tr[x].ch[1] = merge(tr[x].ch[1], y);
    tr[tr[x].ch[1]].fa = x;
    if (tr[tr[x].ch[0]].d < tr[tr[x].ch[1]].d) std::swap(tr[x].ch[0], tr[x].ch[1]);
    tr[x].d = tr[tr[x].ch[1]].d + 1;
    return x;
  }

  inline void pushdown(int x) {
    tr[tr[x].ch[0]].tag += tr[x].tag;
    tr[tr[x].ch[1]].tag += tr[x].tag;
    tr[tr[x].ch[0]].val += tr[x].tag;
    tr[tr[x].ch[1]].val += tr[x].tag;
    tr[x].tag = 0;
  }

  inline int top(int x) { return tr[find(x)].val; }

} Sin, Glo;

inline int read() {
  int res = 0, ch = getchar();
  bool flag = false;
  while (!isdigit(ch)) {
    if (ch == '-') flag = true;
    ch = getchar();
  }
  while (isdigit(ch)) res = (res << 1) + (res << 3) + (ch ^ 48), ch = getchar();
  return flag ? -res : res;
}

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#endif
#ifndef LOCAL
  freopen("P3273 [SCOI2011]棘手的操作.in", "r", stdin);
  freopen("P3273 [SCOI2011]棘手的操作.out", "w", stdout);
#endif
#endif

  n = read();
  int u, v, rt;
  for (int i = 1; i <= n; ++i) {
    Glo.tr[i].val = Sin.tr[i].val = read();
    rt = Glo.merge(rt, i);
  }
  q = read();
  while (q--) {
    scanf("%s", opt);
    if (opt[0] == 'U') {
      u = read(), v = read();
      if (Sin.find(u) != Sin.find(v)) Sin.merge(u, v);
    } else if (opt[0] == 'A') {
      u = read();
      switch (opt[1]) {
        case '1':
          v = read();
          break;
        case '2':
          v = read();
          break;
        default:
          add += u;
      }
    } else {
      switch (opt[1]) {
        case '1':
          break;
        case '2':
          break;
        default:
          printf("%d\n", Glo.top(rt) + add);
      }
    }
  }
  return 0;
}